$(function() {
	init();
})
function init() {
	layui.use('table', function() {
		var table = layui.table;
		table.render({
			height : 20
		});
	});
}

function table(type, id) {
	if (type == 0) {
		x_admin_show('查看权限', 'viewPermission.do?type=' + type + '&id=' + id,
				600, 400)
	} else if (type == 1) {
		x_admin_show('修改权限', 'updateAuth.do?type=' + type + '&id=' + id,
				600, 400)
	} else {
		layer.confirm("确认要删除吗，删除后不能恢复", {
			title : "删除确认"
		}, function(index) {

			$.post("deleteAdministrator.do?id=" + id, function(data) {
				if (data.type == 1) {
					layer.msg("操作成功");
					setTimeout(function() {
						//刷新
						location.reload();
					}, 1000);
				} else {
					layer.msg("操作失败");
					setTimeout(function() {
						//刷新
						location.reload();
					}, 1000);
				}

			}, "json");
		});
	}

}

function resetPwd(id) {
	layer.confirm("确认重置密码？", {icon: 3}, function (){
		$.post('changePasswords.do?id='+id+'&aPassword=123456', function(res) {
			layer.msg("密码已重置为123456！");
		})
	})
}